const program = require("commander")
const {
  createProjectAction,
  addComponentAction,
  addPageAndRouteAction,
  addStoreAction
} = require("./actions")
const createCommands = () => {
  program
    .command('create <project> [other...]')
    .description("clone repository into a folder")
    .action(createProjectAction)

  program
    .command('addcpn <name>')
    .description("add vue component,例如：zyw addcpn HelloWorld [-d src/component]")
    .action((name) => {
      addComponentAction(name, program.dest || 'src/components')
    })

  program
    .command('addpage <page>')
    .description("add vue page and router config,例如：zyw addpage home [-d src/pages]")
    .action((page) => {
      addPageAndRouteAction(page, program.opts().dest || 'src/pages')
    })

  program
    .command('addstore <store>')
    .description("add vue store and router config,例如：zyw addstore home [-d src/pages]")
    .action((store) => {
      addStoreAction(store, program.opts().dest || 'src/store/modules')
    })
}
module.exports = createCommands